package com.wu.community.util;

import com.wu.community.entity.User;
import org.springframework.stereotype.Component;

/**
 @author YanGe
 @create 2022-04-08 15:37
 */

/**
 * 持有用户的信息 用于代替session对象
 */
@Component
public class HostHolder {
    private ThreadLocal<User> users = new ThreadLocal<User>();
    public void setUser(User user){
        users.set(user);
    }
    public User getUser(){
        return users.get();
    }
    public void clear(){
        users.remove();
    }

}
